<?php

namespace Beerus\Modules\Designer\Actions;

use Doraemon\cache\Queue;
use Doraemon\cache\User as CacheUser;
use Doraemon\model\AdmOperateLog;
use Doraemon\model\KaDesigner;
use Encore\Admin\Actions\RowAction;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;
use Doraemon\model\AdmRecommendUser;
use Doraemon\model\AdmBestUser;
use Doraemon\model\Member;

class ContractArchive extends RowAction
{
    public $name = '合同归档';
    const TOAST_ALERT = '是否已确认收到合同，并归档完毕？';

    public function handle($id)
    {
        $data['is_archive'] = KaDesigner::ARCHIVE_NORMAL;
        $result = KaDesigner::updateById($id,$data);
        if ($result){
            return $this->response()->success('归档成功(＾－＾)V')->refresh();
        }else{
            return $this->response()->success('归档失败,请稍后重试o(TωT)o');
        }
    }

    public function retrieveModel(Request $request)
    {
        if (!$key = $request->get('_key')) {
            return false;
        }

        return $key;
    }

    public function dialog()
    {
        $this->confirm(self::TOAST_ALERT);
    }
}
